public class SingleDog {

    public static int find(int[] arr) {
        int dog = 0;
        int i = 0;
        while (i < arr.length-1) {
            arr[i+1] = arr[i] ^ arr[i+1];
            dog = arr[i+1];
            i += 1;
        }
        return dog;
    }

    public static void main(String[] args) {
        int[] arr = {4, 1, 2, 1, 2};
        int ret = find(arr);
        System.out.println(ret);
    }
}
